﻿using PMSWenLvTing.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace PMSWenLvTing.Utility
{
    public class BillCodeHelper
    {
        /// <summary>
        /// 获取结算单号
        /// </summary>
        /// <param name="id">系统用户编号</param>
        /// <returns></returns>
        public static string GetJieSuanBillCode(long id)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("JS");
            sb.Append(DateTime.Now.ToString("yyMMddHHmmss"));
            sb.Append(id.ToString("D3"));
            Random random = new Random();
            int code = random.Next(100);
            sb.Append(code.ToString("D3"));
            return sb.ToString();
        }

        /// <summary>
        /// 获取照片的名字
        /// </summary>
        /// <param name="count">个数</param>
        /// <returns></returns>
        public List<string> GetPhotoNameList(int count)
        {
            List<string> code = new List<string>();
            DateTime now = DateTime.Now;
            DateTime start = new DateTime(2020, 12, 23);
            StringBuilder sb = new StringBuilder();
            //年月日十分秒毫秒
            long TimePart = (long)(now - start).TotalMilliseconds;
            Random rd = new Random();
            for (int i = 0; i < count; i++)
            {
                sb.Clear();
                sb.Append("B");
                sb.Append(TimePart + "_" + count + "_" + rd.Next(1000, 9999));
                code.Add(sb.ToString());
            }
            return code;
        }

        /// <summary>
        /// 获取优惠券号
        /// </summary>
        /// <param name="count">个数</param>
        /// <returns></returns>
        public List<string> GetYouHuiQuanList(int count)
        {
            List<string> code = new List<string>();
            DateTime now = DateTime.Now;
            DateTime start = new DateTime(2019, 01, 14);
            StringBuilder sb = new StringBuilder();
            //年月日十分秒毫秒
            long TimePart = (long)(now - start).TotalMilliseconds;
            for (int i = 0; i < count; i++)
            {
                sb.Clear();
                sb.Append("Q");
                sb.Append(TimePart + count);
                code.Add(sb.ToString());
            }
            return code;
        }

        /// <summary>
        /// 获取GUID列表
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public List<string> GetGUID(int count)
        {
            List<string> lisres = new List<string>();
            for (int i = 0; i < count; i++)
            {
                lisres.Add(Guid.NewGuid().ToString("N"));
            }
            return lisres;
        }

        /// <summary>
        /// 获取报表发布ID
        /// </summary>
        /// <returns></returns>
        public long Get_BBFBID()
        {
            return (long)(DateTime.Now - PublicStaticObject.dt_bbid).TotalMilliseconds;
        }
    }
}